package com.diandian.backend.dingding.data.controller;

import com.diandian.backend.dingding.data.service.DingdingStaffService;
import com.diandian.backend.dingding.data.param.*;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.base.boot.starter.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [钉钉]员工表
 */
@RestController
@RequestMapping("/staff")
public class DingdingStaffController{

    @Autowired
    private DingdingStaffService iDingdingStaffService;

    /**
    * 分页查询
    */
    @PostMapping("/page")
    public BaseResult page(@RequestBody DingdingStaffPageParam param) {
        param.check();
        return ResultUtil.makeResult(iDingdingStaffService.page(param.toDTO()));
    }







    /**
     * 2. 查询详情
     */
    @PostMapping("/detail")
    public BaseResult getDetail(@RequestBody DingdingStaffDetailParam param) {
        return ResultUtil.makeResult(iDingdingStaffService.getDetail(param.toDTO()));
    }

    /**
     * 3. 根据数据id更新数据
     */
    @PostMapping("/updateById")
    public BaseResult updateById(@RequestBody DingdingStaffUpdateByIdParam param) {
        iDingdingStaffService.updateById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 4. 根据数据id删除数据
     */
    @PostMapping("/deleteById")
    public BaseResult deleteById(@RequestBody DingdingStaffDeleteByIdParam param) {
        param.check();
        iDingdingStaffService.deleteById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 5. 新增
     */
    @PostMapping("/add")
    public BaseResult add(@RequestBody DingdingStaffAddParam param) {
        iDingdingStaffService.add(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 7. 列表查询
     */
    @PostMapping("/list")
    public BaseResult list(@RequestBody DingdingStaffListParam param) {
        return ResultUtil.makeResult(iDingdingStaffService.getList(param.toDTO()));
    }

}